<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/6
 * Time: 10:23
 */
if(empty($_POST['user'])){
    echo '用户名为空<br/>';
    echo '<a href="index.php">返回登录</a><br/>';
}elseif (empty($_POST['pwd'])){
    echo '密码为空<br/>';
    echo '<a href="index.php">返回登录</a><br/>';
}else{
    if($_POST['user']!='admin'){
        echo '用户名错误<br/>';
        echo '<a href="index.php">返回登录</a><br/>';
    }elseif ($_POST['pwd']!='888888'){
        echo '密码错误<br/>';
        echo '<a href="index.php">返回登录</a><br/>';
    }else{
        $us = $_POST['user'];
        $pw = $_POST['pwd'];
        $now = time();
        $yestoday = $now-3600*24;
        $sum = md5($us.$pw.$yestoday);
        setcookie('Token',$sum,time()+24*3600);
        header('location:userpage.php');
    }
}